package org.rcy.ruicingmarket.resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 吴康桥
 * @Description
 * @date 2022/10/27 15:04
 */

@Service
@Transactional
public class ApiResourceService {

	@Autowired
	private ApiResourceDao apiResourceDao;

	public void createOrUpdate(ApiResource apiResource){
		if(apiResource.getId() == null) {
			apiResourceDao.insertSelective(apiResource);
		}else {
			apiResourceDao.update(apiResource,true);
		}
	}

	public ApiResource getByName(String name){
		return StringUtils.isBlank(name) ? null : apiResourceDao.getResourceByName(name);
	}

}
